<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="javax.servlet.jsp.JspWriter"%>
<%@page import="org.emergency.framework.model.contactTree.TbPermissionTreeNode"%>
<%@page import="org.emergency.framework.model.contactTree.TbPermissionTree"%>
<%@page import="org.emergency.framework.common.Context"%>
<%@page import="org.emergency.framework.service.common.ITbPermissionTreeService"%>
<%@page import="org.emergency.framework.constant.SessionConstant"%>
<%@page import="org.emergency.framework.common.UserSession"%>
<%@page import="org.emergency.framework.model.TbPermission"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<base href="<%=basePath%>">
<head>

<jsp:include page="common/Head.jsp" ></jsp:include>
<%--
costom
--%>

<script type="text/javascript" src="js/imgload.js"></script>
		<script type="text/javascript" src="js/left.js"></script>

<script src="oa/permission/leftpermissionTree.js" type="text/javascript"></script>

<script type="text/javascript">
	
	</script>


<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	height: 100%;
}

.STYLE2 {
	color: #43860c;
	font-size: 12px;
}

a:link {
	font-size: 12px;
	text-decoration: none;
	/*
	color: #06527d;*/
	color: #43860c;
}

a:visited {
	font-size: 12px;
	text-decoration: none;
	color: #43860c;
}

a:hover {
	font-size: 12px;
	text-decoration: none;
	/*
	color: #FF0000;*/
	color: #43860c;
}

.menuClick {
	cursor: pointer;
}



/*
一级菜单标题
*/
.menuClick td {
	text-align: center;
	font-weight: bold;
	color: #633;
}

.menuContent {
	display: none;
}

.scrollDiv {
	overflow: auto;
	overflow-x: hidden;
}

/*
*二级菜单
*/
.secondmenuClick {
	cursor: pointer;
}

.secondmenuClick td {
	padding-left:30px;
	text-align: left;
	font-weight: bold;
	color: #633;
}

.secondmenuContent {
	display: none;
}

.fourmenuClick td {
	padding-left:50px;
	text-align: left;
	font-weight: bold;
	color: #633;
}

/*
*三级菜单
*/

.thirdmenuClick {
	cursor: pointer;
	
}

.thirdmenuClick td {
	padding-left:0px;
	text-align: left;
	font-weight: bold;
	color: #633;
}
.thirdmenuContent {
	display: none;
	text-align:center;
	
}
.thirdmenuContent a{
	font-weight: bold;
}
.threeimg{
	margin-right:3px;
}
.fourlayer{
	height:20px;
}
-->
</style>


	<script type="text/javascript" language="javascript">
		$(function(){
		$(".qxgl").click(function(){	
				 $('#tabFrame', window.parent.document).attr("src", $(this).attr("value"));
		});
		});
		</script>
</head>
<body
		onload="MM_preloadImages('img/main_26_1.gif','img/main_29_1.gif','img/main_31_1.gif')">
		<table width="177" height="100%" border="0" cellpadding="0"
			cellspacing="0">
			<tr>
				<td valign="top">
					<table width="100%" border="0" cellspacing="0" cellpadding="0"
						style="table-layout: fixed">

						<tr>
							<td height="26" background="img/main_21.gif">
								<span id="roleSP"
									style="font-size: 14px; left: 50%; color: #900; position: relative"></span>
							</td>
						</tr>
						<%--
						把node下的树都放下来，l为0时即第0级，1时为每1级，。。。以此实现层次的划分,暂时只做到一级和二级，若想加级，可直接
						 if(l==?){
						 }
						 permissions为一字符串集合，用来判断权限id是否为用户所有
						--%>
		<%!public void printLocalTree(TbPermissionTreeNode node, ServletRequest request,
			ServletResponse response, JspWriter out,int l,List<String> permissions) throws Exception {
			l++;
			if(l==0){//0级菜单，不显示
				List<TbPermissionTreeNode> nodeList = node.getChildren();
				for (int i = 0; i < nodeList.size(); i++) {
					printLocalTree(nodeList.get(i), request, response, out,l,permissions);
				}
			}else if(l==1&&permissions.contains(node.getNodeId())){ //1级菜单
			out.println("<tr class='menuClick'><td height='26' background='oa/user/images/clickOut.gif'>");
				out.println(node.getName());
			out.println("</td></tr>");
			out.println("<tr class='menuContent'><td style='background-image: url(oa/user/images/main_23.gif);"+
			"background-repeat: repeat-x; padding-top: 5px;'>"
			+"<div class='scrollDiv'><table width='98%' border='0' align='center' cellpadding='0' ellspacing='0'>");
		List<TbPermissionTreeNode> nodeList = node.getChildren();
		for (int i = 0; i < nodeList.size(); i++) {
			printLocalTree(nodeList.get(i), request, response, out,l,permissions);
		}
		out.println("</table></div></td></tr>");
		}else if(l==2&&permissions.contains(node.getNodeId())){//2级菜单
			out.println("<tr class='secondmenuClick'><td height='25'><div ><img src='oa/user/images/secondmenuhead.png'/>"
			+"<a href='javascript:;' value="+node.getDesc()+" class='qxgl' id=''>");
			out.println(node.getName());
			out.println("</a></div></td></tr>");
			out.println("<tr></tr>");
		}
			l--;
		
	}%>
		<%
		TbPermissionTree permissionTree = ((ITbPermissionTreeService) Context.webApplicationContext
					.getBean("tbPermissionTreeServiceImpl")).getTbRoleTreeTree();
		TbPermissionTreeNode node = permissionTree.getRootNode();
		
		List<String> permissionStringList = Context.getPermissonString();
		
			printLocalTree(node, request, response, out,-1,permissionStringList);
		%>
						</table>
						</td>
						</tr>
						</table>
</body>
</html>
